Coder 灰桑

Stay Foolish, Always Foolish

在 Playground 中编译 SwiftUI 的代码

记录下在 Playground 中编译 SwiftUI 的代码。

import SwiftUI
import PlaygroundSupport

struct ContentView: View {
    @State var counter = 0
    var body: some View {
        VStack {
            Button(action: { self.counter += 1 }, label: {
                Text("Tap me!")
                    .padding()
                    .background(Color(.tertiarySystemFill))
                    .cornerRadius(5)
            })
            if counter > 0 {
                Text("You've tapped \(counter) times")
            } else {
                Text("You've not yet tapped")
            }
        }
    }
}

PlaygroundPage.current.setLiveView(ContentView())

截屏2020-05-14 上午11.43.34
🔙  SwiftUI - 开发图片模糊的 MAC 小应用
命令行备忘  🔜